package models;


import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import play.db.jpa.Model;

@Entity
public class Turma extends Model {

	public String cod;
	public int vagas;
	public String local;
	public String horaInicio;
	public String horaFim;
	public Date dataInicio;
	public boolean ativa;
	public String diasDaSemana;

	@Transient
	public Long numAlunosServidores;
	@Transient
	public Long numAlunosBolsistas;
	@Transient
	public Long numAlunosPagantes;
	
	@ManyToOne
	public Professor professor;

	@ManyToOne
	public Nivel_Semestre nivelSemestre;
	
	@OneToMany(mappedBy="turma")
	public List<Matricula> matriculas;

	@Override
	public int hashCode() {
		Long i = this.id;
		return 31 + ((i == null) ? 0 : i.hashCode());
	}
	
	@Override
	public boolean equals(Object o) {
		
		if (o instanceof Turma) {			
			Turma t = (Turma) o;			
			if (t.id == this.id && t.cod.equals(this.cod) )			
				return true;
		}		
		return false;
	}
}
